package com.ruoyi.customer.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.customer.common.DisCustomerRequestBo;
import com.ruoyi.customer.domain.TotalComster;
import com.ruoyi.customer.service.ITotalComsterService;
import com.ruoyi.enums.BusTypeEnum;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author suntf
 * @since 2023-08-24
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/totalComster")
public class TotalComsterController {

    private final ITotalComsterService iTotalComsterService;

    /**
     * 查询客户信息列表
     */
    //@SaCheckPermission("total:customer:list")
    @GetMapping("/list")
    public TableDataInfo<TotalComster> list(TotalComster bo, PageQuery pageQuery) {
        return iTotalComsterService.queryPageList(bo, pageQuery);
    }

    /**
     * 导入公司公海
     *
     * @param totalComsterList
     * @return
     */
    @SaCheckPermission("total:customer:transformerCustomer")
    @PostMapping("transformerCustomer")
    public R transformerCustomer(@RequestBody List<Long> totalComsterList) {
        return iTotalComsterService.transformerCustomer(totalComsterList);
    }


    /**
     * 一键下发给部门
     *
     * @param
     * @return
     */
    @PostMapping("oneKeyIssueToDept")
    public R oneKeyIssueToDept(@RequestBody DisCustomerRequestBo requestBo) {
        return iTotalComsterService.oneKeyIssueToDept(requestBo, BusTypeEnum.TOTAL_CUSTOMER.getCode());
    }

    /**
     * 一键下发给业务员
     *
     * @param issueBo
     * @return
     */
    @PostMapping("oneKeyIssueToUser")
    public R oneKeyIssueToUser(@RequestBody DisCustomerRequestBo issueBo) {
        return iTotalComsterService.oneKeyIssueToUser(issueBo, BusTypeEnum.TOTAL_CUSTOMER.getCode());
    }

    /**
     * 删除数据
     *
     * @param id
     * @return
     */
    @SaCheckPermission("total:customer:delCustomer")
    @PostMapping("delCustomer/{id}")
    public R delCustomer(@PathVariable("id") String id) {
        return iTotalComsterService.delCustomer(id);
    }

    /**
     * 操作日志
     *
     * @return
     */
//    @SaCheckPermission("total:customer:updateRemark")
    @PostMapping("updateRemark")
    public R updateRemark(@RequestBody TotalComster totalComster) {
        return iTotalComsterService.updateRemark(totalComster);
    }

    @PostMapping("updateCustomerName")
    public R updateCustomerName(@RequestBody TotalComster totalComster) {
        return iTotalComsterService.updateCustomerName(totalComster);
    }

    @PostMapping("updateCustomerStatus")
    public R updateCustomerStatus(@RequestBody TotalComster totalComster) {
        return iTotalComsterService.updateCustomerStatus(totalComster);
    }

    @PostMapping("updateCustomerLevel")
    public R updateCustomerLevel(@RequestBody TotalComster totalComster) {
        return iTotalComsterService.updateCustomerLevel(totalComster);
    }
}
